import api from "@/utils/api.js"
import request from "@/utils/request.js"

// Promise
export default (params) => {
    uni.showLoading({
        title: '加载中'
    });
    return new Promise((reslove, reject) => {
        wx.request({
            ...params,
            success: function(res) {
                reslove(res)
            },
            fail: function(err) {
                reject(err)
            },
            complete: function() {
                uni.hideLoading();
            }
        })
    })
}

/*
 * 目标区接口
 */

// 获取目标分类
export function t_GetCate() {
    return request({ url: api.t_GetCate })
}

// 获取目标列表
export function t_GetList() {
    return request({ url: api.t_GetList })
}

// 添加目标
export function t_AddTarget(data) {
    return request({ url: api.t_AddTarget, data: data, method: "POST", header: { "Content-Type": "application/x-www-form-urlencoded" } })
}

// 添加目标分类
export function t_AddCate(data) {
    return request({ url: api.t_AddCate, data: data, method: "POST", header: { "Content-Type": "application/x-www-form-urlencoded" } })
}

// 删除目标分类
export function t_DelCate(data) {
    return request({ url: api.t_DelCate, data: data })
}

// 删除目标
export function t_DelTarget(data) {
    return request({ url: api.t_DelTarget, data: data })
}


/*
 * 收藏区接口
 */

// 获取收藏分类
export function c_GetCate() {
    return request({ url: api.c_GetCate })
}

// 添加收藏分类
export function c_AddCate(data) {
    return request({ url: api.c_AddCate, data: data, method: "POST", header: { "Content-Type": "application/x-www-form-urlencoded" } })
}

// 根据id获取分类
export function c_GetCateById(data) {
    return request({ url: api.c_GetCateById, data: data })
}

// 根据id删除分类
export function c_DelCate(data) {
    return request({ url: api.c_DelCate, data: data })
}

// 获取分类对应的内容列表
export function c_GetContentById(data) {
    return request({ url: api.c_GetContentById, data: data })
}

// 修改或添加内容
export function c_EditContent(data) {
    return request({ url: api.c_EditContent, data: data, method: "POST", header: { "Content-Type": "application/x-www-form-urlencoded" } })
}

// 删除内容
export function c_DelContent(data) {
    return request({ url: api.c_DelContent, data: data })
}

/*
 * 记录区接口
 */

export function r_GetList() {
    return request({ url: api.r_GetList })
}

export function r_GetContentById(data) {
    return request({ url: api.r_GetContentById, data: data })
}


/*
 * 日记区接口
 */

export function j_GetListById(data) {
    return request({ url: api.j_GetListById, data: data })
}

export function j_GetContent(data) {
    return request({ url: api.j_GetContent, data: data })
}

export function j_EditContent(data) {
    return request({ url: api.j_EditContent, data: data, method: "POST", header: { "Content-Type": "application/x-www-form-urlencoded" } })
}

export function j_DelContent(data) {
    return request({ url: api.j_DelContent, data: data })
}

/*
 * 感悟区接口
 */

export function s_GetListById(data) {
    return request({ url: api.s_GetListById, data: data })
}

export function s_GetContent(data) {
    return request({ url: api.s_GetContent, data: data })
}

export function s_EditContent(data) {
    return request({ url: api.s_EditContent, data: data, method: "POST", header: { "Content-Type": "application/x-www-form-urlencoded" } })
}

export function s_DelContent(data) {
    return request({ url: api.s_DelContent, data: data })
}

/*
 * 日程区接口
 */

export function trip_GetListById(data) {
    return request({ url: api.trip_GetListById, data: data })
}

export function trip_GetContent(data) {
    return request({ url: api.trip_GetContent, data: data })
}

export function trip_EditContent(data) {
    return request({ url: api.trip_EditContent, data: data, method: "POST", header: { "Content-Type": "application/x-www-form-urlencoded" } })
}

export function trip_EditChecked(data) {
    return request({ url: api.trip_EditChecked, data: data })
}

export function trip_DelContent(data) {
    return request({ url: api.trip_DelContent, data: data })
}

/*
 * 相册区接口
 */

export function album_GetListById(data) {
    return request({ url: api.album_GetListById, data: data })
}

export function album_GetContent(data) {
    return request({ url: api.album_GetContent, data: data })
}

export function album_EditContent(data) {
    return request({ url: api.album_EditContent, data: data, method: "POST", header: { "Content-Type": "application/x-www-form-urlencoded" } })
}

export function album_EditChecked(data) {
    return request({ url: api.album_EditChecked, data: data })
}

export function album_DelContent(data) {
    return request({ url: api.album_DelContent, data: data })
}

export function album_GetToken(data) {
    return request({ url: api.album_GetToken, data: data })
}

export function album_UpImage(data) {
    return request({ url: api.album_UpImage, data: data })
}

export function hongquTest(data) {
    return request({ url: api.hongquTest, data: data, method: "POST", header: { "Content-Type": "application/x-www-form-urlencoded" } })
}